var a = require("../../../mybehaviors/location/location"), t = getApp();

Component({
    behaviors: [ a ],
    properties: {
        datas: {
            type: null
        },
        component_id: {
            type: null
        },
        bottomShowBolIndex: {
            type: null
        },
        index: {
            type: null
        },
        U_tabcontrol: {
            type: null
        },
        bottomShowBol: {
            type: null
        },
        isLast: {
            type: null
        }
    },
    data: {
        emptyImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png",
        clientWidth: "375",
        list: [],
        language: "",
        goodsShow: !0,
        page: 1,
        total_page: 0,
        isLoadMore: !0,
        allLoaded: !1
    },
    lifetimes: {
        attached: function() {
            var a = wx.getStorageSync("langIndex");
            if (wx.getStorageSync("yz_basic_info").lang) {
                var t = wx.getStorageSync("yz_basic_info").lang.goods, e = t && t.vip_price ? t.vip_price : "会员价";
                this.setData({
                    vip_price_txt: e
                });
            }
            this.setData({
                language: a.en
            });
        },
        moved: function() {},
        detached: function() {}
    },
    attached: function() {},
    ready: function() {
        var a = this;
        this.setData({
            clientWidth: wx.getSystemInfoSync().windowWidth,
            list: this.data.datas.list.data ? this.data.datas.list.data : this.data.datas.list
        }), this._getLocation(function(e, o) {
            var s = t.qqMapTransBMap(parseFloat(o.lng), parseFloat(o.lat));
            a.setData({
                lat: s.lat,
                lng: s.lng,
                point: s
            }), a.getdata();
        });
    },
    pageLifetimes: {
        show: function() {},
        hide: function() {},
        resize: function() {}
    },
    methods: {
        gotoDetail: function(a) {
            var t = a.currentTarget.dataset.item.goodid;
            wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + t
            });
        },
        getMoreData: function() {
            var a = this;
            if (a.setData({
                isLoadMore: !1
            }), !(a.data.page >= a.data.last_page)) {
                a.setData({
                    page: a.data.page + 1
                });
                var e = t.getNetAddresss("plugin.nearby-store-goods.frontend.controllers.designer.get-goods");
                e += "&page=" + a.data.page, e += "&lng=" + a.data.point.lng, e += "&lat=" + a.data.point.lat, 
                e += "&city_name=" + a.data.city, t._getNetWork({
                    url: e,
                    success: function(t) {
                        var e = t.data;
                        if (1 == e.result) {
                            a.setData({
                                last_page: e.data.last_page
                            }), a.data.page < a.data.last_page ? a.setData({
                                isLoadMore: !0
                            }) : a.setData({
                                allLoaded: !0
                            });
                            var o = a.data.list.concat(e.data.data);
                            a.setData({
                                list: o
                            });
                        } else a.setData({
                            page: a.data.page - 1,
                            isLoadMore: !1,
                            allLoaded: !0
                        });
                    },
                    fail: function(a) {
                        console.log(a);
                    }
                });
            }
        },
        getdata: function() {
            var a = this, e = t.getNetAddresss("plugin.nearby-store-goods.frontend.controllers.designer.get-goods");
            e += "&page=" + a.data.page, e += "&lng=" + a.data.point.lng, e += "&lat=" + a.data.point.lat, 
            e += "&city_name=" + a.data.city, t._getNetWork({
                url: e,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? (a.setData({
                        isLoadMore: !1,
                        last_page: e.data.last_page
                    }), e.data.current_page < e.data.last_page ? a.setData({
                        isLoadMore: !0
                    }) : a.setData({
                        allLoaded: !0
                    }), a.setData({
                        list: e.data.data
                    })) : a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1,
                        allLoaded: !0
                    });
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    observers: {
        bottomShowBol: function(a) {
            a && this.data.bottomShowBolIndex == this.data.index && 5 != this.data.datas.sort_style.choose_icon && this.data.isLoadMore && this.getMoreData();
        }
    }
});